﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PopupAddResumeImage.aspx.cs"
    Inherits="iOak.Web.Popups.PopupAddResumeImage" %>

<%@ Register Src="~/BaseModuleControls/ConfirmBox.ascx" TagName="ConfirmBox" TagPrefix="CatLrs" %>
<%@ Register Src="~/BaseModuleControls/Alert.ascx" TagName="Alert" TagPrefix="CatLrs" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>图片上传</title>
    <base target="_self" />
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
    <meta http-equiv="expires" content="0" />
    <link type="text/css" href="/Style/style.css" rel="stylesheet" />
    <link type="text/css" href="/Style/list.css" rel="stylesheet" />
    <link type="text/css" href="/Style/index.css" rel="stylesheet" />
    <link type="text/css" href="/Style/Site.css" rel="stylesheet" />
    <link type="text/css" href="/Script/jqueryui/css/jquery-ui-1.8.16.css" rel="stylesheet" />
    <script type="text/javascript" src="/Script/jquery-1.6.2.min.js"></script>
    <script type="text/javascript" src="/Script/jqueryui/js/jquery-ui-1.8.16.min.js"></script>
    <script type="text/javascript" src="/Script/jqueryui/js/jquery.ui.datepicker-zh-CN.js"></script>
</head>
<body>
    <form id="form1" runat="server">
    <ajaxToolkit:ToolkitScriptManager runat="server" ID="sm1" EnableScriptGlobalization="true"
        EnableScriptLocalization="true" ScriptMode="Release" CompositeScript-ScriptMode="Release" />
    <script type="text/javascript">
        window.onbeforeunload = function () {
            var n = window.event.screenX - window.screenLeft;
            var b = n > document.documentElement.scrollWidth - 20;
            if (b && window.event.clientY < 0 || window.event.altKey) {
                document.getElementById("<%=buttonClose.ClientID%>").click();

            }
        }

        $(function () {
            addFileUploadZone();

            // 选择事件
            var cbHeader = $(".cbHeader input");
            var cbRowItem = $(".cbRowItem input");
            cbHeader.bind("click", function () {
                cbRowItem.each(function () {
                    this.checked = cbHeader[0].checked;
                })
            });
            cbRowItem.bind("click", function () {
                if (this.checked == false) {
                    cbHeader[0].checked = false;
                }
            });
        });
        function addFileUploadZone() {
            //插入新的附件上传域

            var newAttachment = $('.attachmentSelect').clone().appendTo('.attchmentZone');
            $('<br/>').appendTo('.attchmentZone');

            //移除样式
            newAttachment.removeClass();
        }

        // 上传调用进度条事件

        function uploadPostBack() {

            var buttonPostBack = $('#<%=buttonPostBack.ClientID %>');
            buttonPostBack.click();
            return true;

        }

        // 上传前先判断
        function showUpload() {
            var buttonProgress = $('#<%=buttonProgress.ClientID %>');
            buttonProgress.click();
            return false;
        }

        // 删除时判断

        function CheckSelectList() {
            var cbRowItem = $(".cbRowItem input");
            var cknum = 0;
            cbRowItem.each(function () {
                if (this.checked) {
                    cknum = cknum + 1;
                };
            })
            if (cknum == 0) {
                var messageLabel = $('#<%=messageBox.MessageLabel.ClientID %>');
                messageLabel.text('请选择需要删除的数据！');
                var buttonMessage = $('#<%=buttonMessage.ClientID %>');
                buttonMessage.click();
            }
            else {
                var cmtconfirmBox = $('#<%=confirmBox.MessageLabel.ClientID %>');
                cmtconfirmBox.text('确定删除？');
                var buttonConfirm = $('#<%=buttonConfirm.ClientID %>');
                buttonConfirm.click();
            }
            return false;
        }
        
    </script>
    <div class="pageheader" runat="server" id="divName" style="padding-left: 10px; padding-top: 10px">
        <label runat="server" id="lblName">
        </label>
    </div>
    <div runat="server" id="divActiveList" style="width: 98%; padding: 10px;">
        <asp:Label ID="lblTitle" runat="server" Text="图片上传" Font-Size="Large" Font-Bold="True"
            ForeColor="#666633"></asp:Label>
        <div style="width: 98%; text-align: right;">
            <asp:Button ID="buttonSave" runat="server" Text="保存" CssClass="adminButtonBlue" OnClick="ButtonSave_Click" />
            &nbsp;&nbsp;
            <asp:Button ID="buttonUpload" runat="server" Text="上传" CssClass="adminButtonBlue" />
            &nbsp;&nbsp;
            <asp:Button ID="buttonDelete" runat="server" Text="删除" CssClass="adminButtonBlue"
                OnClientClick="return CheckSelectList();" />
            &nbsp;&nbsp;
            <asp:Button ID="buttonClose" runat="server" Text="关闭" CssClass="adminButtonBlue"
                OnClick="ButtonClose_Click" />
            &nbsp;&nbsp;
        </div>
    </div>
    <p>
    </p>
    <div id="divImage" runat="server" style="width: 98%; padding-left: 1%; height: 720px;
        overflow-y: scroll;">
        <asp:GridView runat="server" ID="gvImageList" Width="100%" AutoGenerateColumns="false"
            CssClass="tab1" OnRowDataBound="gvImageList_RowDataBound">
            <HeaderStyle CssClass="tab1_green" />
            <RowStyle CssClass="itemRow" />
            <AlternatingRowStyle CssClass="alternatingRow" />
            <Columns>
                <asp:TemplateField>
                    <HeaderTemplate>
                        <asp:CheckBox ID="cbSelectAll" runat="server" CssClass="cbHeader" />
                    </HeaderTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="checkBoxImageShow" runat="server" CssClass="cbRowItem" />
                        <asp:HiddenField ID="hidAttachmentId" runat="server" Value='<%# Eval("AttachmentId")%>' />
                    </ItemTemplate>
                    <ItemStyle Width="5%" HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:TemplateField>
                 <asp:TemplateField HeaderText="标题">
                    <ItemTemplate>
                        <asp:Label runat="server" ID="lblTitle" Text='<%#Server.HtmlEncode( Eval("Caption").ToString())%>'></asp:Label>
                        <asp:TextBox ID="textBoxOrder" runat="server" Width="98%" MaxLength="50" Text='<%#Server.HtmlEncode( Eval("Caption").ToString())%>'>
                        </asp:TextBox>
                    </ItemTemplate>
                    <ItemStyle Width="20%" VerticalAlign="Middle" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="图片">
                    <ItemTemplate>
                        <asp:ImageButton runat="server" ID="imageButtonEdit" Width="75px" Height="55px" ImageUrl='<%# "~/Popups/AttachementShow.ashx?AttachmentId=" + Eval("AttachmentId") %>' />
                        <ajaxToolkit:ModalPopupExtender runat="server" ID="modalPopupExtenderShowImages"
                            TargetControlID="imageButtonEdit" OkControlID="buttonClose" PopupControlID="panelShowImages"
                            BackgroundCssClass="modalBackground" />
                        <asp:Panel ID="panelShowImages" runat="server" Style="display: none; width: 1000px;
                            background-color: White; border-width: 2px; border-color: Black; border-style: solid;
                            padding: 20px;">
                            <p>
                            </p>
                            <div style="text-align: right; float: inherit; width: 1000px;">
                                <asp:LinkButton ID="buttonClose" runat="server" OnClientClick="return false;" Text="X"
                                    ToolTip="Close" Style="background-color: #666666; color: #FFFFFF; text-align: center;
                                    font-weight: bold; text-decoration: none; border: outset thin #FFFFFF; padding: 5px;" />
                            </div>
                            <p>
                            </p>
                            <div style="text-align: center; float: inherit; overflow: scroll; vertical-align: middle;
                                width: 1000px; height: 580px;">
                                <asp:Image ID="imageShow" runat="server" ImageUrl='<%# "~/Popups/AttachementShow.ashx?AttachmentId=" + Eval("AttachmentId") %>' />
                            </div>
                        </asp:Panel>
                        <asp:FileUpload Width="100%" runat="server" ID="fileUpload" />
                    </ItemTemplate>
                    <ItemStyle Width="20%" HorizontalAlign="Center" VerticalAlign="Middle" />
                </asp:TemplateField> 
                <asp:TemplateField HeaderText="页码">
                    <ItemTemplate>
                        <asp:Label runat="server" ID="lblPageNumber" Text='<%#Server.HtmlEncode( Eval("PageNumber").ToString())%>'></asp:Label>
                        <asp:TextBox ID="textBoxPage" runat="server" MaxLength="10"
                            Width="98%" Text='<%#Server.HtmlEncode( Eval("PageNumber").ToString())%>'>
                        </asp:TextBox>
                    </ItemTemplate>
                    <ItemStyle Width="10%" VerticalAlign="Middle" />
                </asp:TemplateField>     
                <asp:TemplateField HeaderText="描述">
                    <ItemTemplate>
                        <asp:Label runat="server" ID="lblCommon" Text='<%#Server.HtmlEncode( Eval("Brief").ToString())%>'></asp:Label>
                        <asp:TextBox ID="textBoxCommon" TextMode="MultiLine" Height="55px" runat="server"
                            Width="98%" Text='<%#Server.HtmlEncode( Eval("Brief").ToString())%>'>
                        </asp:TextBox>
                    </ItemTemplate>
                    <ItemStyle Width="40%" VerticalAlign="Middle" />
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <asp:Button ID="button1" runat="server" Visible="false" Text="批量上传" CssClass="adminButtonBlue"
            OnClick="button1_Click" />
        &nbsp;&nbsp;
    </div>
    <div style="display: none">
        <table style="width: 600px;" class="attachmentSelect">
            <tr>
                <td class="editor-label" style="width: 24%">
                    浏览:
                </td>
                <td class="editor-field" style="width: 76%">
                    <input id="upfile" type="file" name="File" onchange="return addFileUploadZone();"
                        runat="server" style="width: 98%" class="uploadFile" />
                </td>
            </tr>
            <tr>
                <td class="editor-label" style="width: 24%">
                    标题:
                </td>
                <td class="editor-field" style="width: 76%">
                    <asp:TextBox ID="textBoxDisplayOrder" CssClass="editor-required" runat="server" Width="98%"
                        MaxLength="50"></asp:TextBox>
                </td>
            </tr>
             <tr>
                <td class="editor-label" style="width: 24%">
                    页码:
                </td>
                <td class="editor-field" style="width: 76%">
                    <asp:TextBox ID="textBoxPageNumber" runat="server" Width="10%"
                        MaxLength="10"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="editor-label" style="width: 12%">
                    描述:
                </td>
                <td class="editor-field" colspan="3">
                    <asp:TextBox ID="textBoxDescription" runat="server" Width="98%" TextMode="MultiLine"
                        Height="30px"></asp:TextBox>
                </td>
            </tr>
        </table>
    </div>
    <ajaxToolkit:ModalPopupExtender runat="server" ID="modalPopupExtenderUploadImages"
        TargetControlID="buttonUpload" OkControlID="buttonOk" OnOkScript="return showUpload();"
        CancelControlID="buttonCancel" PopupControlID="panelUploadImages" BackgroundCssClass="modalBackground" />
    <asp:Panel runat="server" ID="panelUploadImages" Style="display: none; width: 650px;
        background-color: White; border-width: 2px; border-color: Black; border-style: solid;
        padding: 20px;">
        <div>
            <table>
                <tr>
                    <td style="width: 650px; text-align: right;">
                        <asp:Button ID="buttonOk" runat="server" Text="确定" CssClass="adminButtonBlue" CausesValidation="false" />
                        &nbsp;&nbsp;&nbsp;
                        <asp:Button ID="buttonCancel" runat="server" Text="取消" CssClass="adminButtonBlue"
                            CausesValidation="false" />
                    </td>
                </tr>
            </table>
        </div>
        <div style="text-align: center; width: 650px; height: 450px; overflow-y: scroll;"
            class="attchmentZone">
        </div>
    </asp:Panel>
    <asp:Button runat="server" ID="buttonConfirm" OnClick="ButtonConfirm_Click" CssClass="hidden" />
    <asp:Button runat="server" ID="buttonProgress" OnClick="ButtonProgressd_Click" CssClass="hidden" />
    <asp:Button runat="server" ID="buttonLoading" CssClass="hidden" />
    <asp:Button runat="server" ID="buttonPostBack" OnClick="ButtonPostBack_Click" CssClass="hidden" />
    <ajaxToolkit:ModalPopupExtender ID="modalPopupExtenderAlert" runat="server" PopupControlID="panelPopup"
        TargetControlID="buttonLoading" Drag="true" BackgroundCssClass="modalBackground" />
    <asp:Panel ID="panelPopup" runat="server" Style="display: none; width: 480px; background-color: White;
        border-width: 2px; border-color: Black; border-style: solid; padding: 20px;">
        <div style="text-align: center; float: inherit; vertical-align: middle; width: 480px;">
            <img src="/Images/Progressbar.gif" />
        </div>
        <div style="text-align: center; float: inherit; width: 480px;">
            <img src="/Images/Loading.gif" />
        </div>
    </asp:Panel>
    <asp:Button runat="server" ID="buttonMessage" CssClass="hidden" />
    <CatLrs:ConfirmBox ID="confirmBox" TargetControlId="buttonConfirm" runat="server" />
    <CatLrs:Alert ID="messageBox" TargetControlId="buttonMessage" runat="server" />
    <asp:HiddenField ID="hidResumeId" runat="server" />
    <asp:HiddenField ID="hiddenFieldDescription" runat="server" />
    <asp:HiddenField ID="hiddenFieldDisplayOrder" runat="server" />
    <asp:HiddenField ID="hiddenFieldPageNumber" runat="server" />
    <asp:HiddenField ID="hidcampaignId" runat="server" />
    <asp:HiddenField ID="hidSelectedAttaches" runat="server" />
    </form>
</body>
</html>
